<template>
	<div class="main">
		<van-field label="危险作业类型" v-model="data.DangerOperateTypeName" name="title" readonly>
		</van-field>

		<van-field label="上报日期" v-model="data.ApplyDate" name="title" readonly>
		</van-field>

		<van-field label="位置" v-model="data.Location" name="title" readonly>
		</van-field>

		<van-field label="作业方" v-model="data.OperateObjName" name="title" readonly>
		</van-field>

        <van-field label="开始日期" v-model="data.StartDate" name="title" readonly>
		</van-field>

        <van-field label="结束日期" v-model="data.EndDate" name="title" readonly>
		</van-field>

        <van-field label="作业人员" v-model="data.OperateChnName" name="title" readonly>
		</van-field>

        <van-field label="监护人员" v-model="data.WatchMan" name="title" readonly>
		</van-field>

		<van-field label="录入人" v-model="data.CreateChnName" name="title" readonly>
		</van-field>

		<van-field label="录入时间" v-model="data.CreateDate" name="title" readonly>
		</van-field>

		
		<FileUpload
        @CallBack="_fileUploadCb"
        :attachs="data.Attachs"
        :labelName="'施工作业记录'"
        :allowEdit="false"
        />

		<FileUpload
		v-if="data.Status >= 100"
        @CallBack="fileUploadCb"
        :attachs="data.ConstructionEndFile"
        :labelName="'施工结束记录'"
        :allowEdit="false"
      />


	</div>
</template>

<script>
import FileListReadOnly from "../../../components/Attach/FileListReadOnlyYat.vue";
export default {
	components: { FileListReadOnly },
	data() {
		return {
			id: this.$route.query.id,
			data: {
				
			},
			templateId: this.$route.query.templateId,
		}
	},
	beforeMount () {
		this.data = []

	},
	created() {
		this.getDetail();

	},
	activated() {},
	methods: {
		getDetail() {
            // GET /api/SiteDangerOperateApplyRecordNew/GetDetail/{id}
			let params = { id: this.id };
			this.$axios
				.get('/SiteDangerOperateApplyRecordNew/GetDetail/{id}', { params: params })
				.then((res) => {
				
				 res.data.DangerOperateTypeList.forEach((item) => {
					if (res.data.DangerOperateType == item.ID) {
						res.data.DangerOperateType = item.ID;
						res.data.DangerOperateTypeName = item.Name;
						}
					});
					this.SitdangerType  = res.data.DangerOperateType
					res.data.OperateObjList.forEach((item) => {
						if (res.data.OperateObj == item.ID) {
						res.data.OperateObj = item.ID;
						res.data.OperateObjName = item.Name;
						}
					});
					this.SitridoType  = res.data.OperateObj
				// console.log(Object.keys(res.data.ApplyDate).length);
				
				if(res.data.ApplyDate && res.data.ApplyDate.length > 10){
					res.data.ApplyDate = res.data.ApplyDate.substring(0,10);			
				}

				if(res.data.StartDate && res.data.StartDate.length > 10){
					res.data.StartDate = res.data.StartDate.substring(0,10);
				}
				if(res.data.EndDate && res.data.EndDate.length > 10){
					res.data.EndDate = res.data.EndDate.substring(0,10);
				}
				if(res.data.CreateDate && res.data.CreateDate.length > 10){
					res.data.CreateDate = res.data.CreateDate.substring(0,10);
				}
				
				console.log(res.data.ApplyDate)

				this.data = res.data;
				
				});
		},
		fileUploadCb(attachs) {
			this.data.ConstructionEndFile = attachs;
		},
		_fileUploadCb(attachs) {
			this.data.Attachs = attachs;
		},
		initNewEntity() {
			this.$axios
				.get('/YatManagementDocsApi/InitNewEntity', {})
				.then((res) => {
				this.data = res.data;
				});
		},
		
	},
}
</script>